/**
 ******************************************************************************
 * @file           : main.c
 * @brief          : I2C MPU6050 Sensor Example
 ******************************************************************************
 */

#include "stm32f4xx.h"
#include "./BSP/IIC/bsp_iic.h"
#include "./Devices/MPU6050/bsp_mpu6050.h"
#include "./BSP/USART/bsp_usart.h"
#include <stdio.h>

int main(void)
{
    HAL_Init();
    SystemClock_Config();

    usart_init(115200);
    iic_init();

    printf("I2C MPU6050 Sensor Example\r\n");

    if (mpu6050_init() != 0)
    {
        printf("MPU6050 initialization failed\r\n");
        while (1);
    }

    MPU6050_Data_t mpu_data;

    while (1)
    {
        if (mpu6050_read_data(&mpu_data) == 0)
        {
            printf("Accel: X=%d, Y=%d, Z=%d\r\n",
                   mpu_data.accel_x, mpu_data.accel_y, mpu_data.accel_z);
            printf("Gyro: X=%d, Y=%d, Z=%d\r\n",
                   mpu_data.gyro_x, mpu_data.gyro_y, mpu_data.gyro_z);
            printf("Temp: %d\r\n\r\n", mpu_data.temperature);
        }

        HAL_Delay(500);
    }
}

void SystemClock_Config(void)
{
    /* 同上 */
}
